package com.okaixz.client.controller;


import com.okaixz.client.model.domain.TaskInfo;
import com.okaixz.client.model.vo.QianDaoInfoVo;
import com.okaixz.client.service.ITaskInfoService;
import com.okaixz.common.annotation.OpLog;
import com.okaixz.common.client.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cdz
 * @since 2025-06-11
 */
@RestController
@RequestMapping("/kb/task")
public class TaskInfoController {

    @Autowired
    private ITaskInfoService  taskInfoService;

    @GetMapping("/list/{clientName}")
    public Result<List<TaskInfo>> getListByClientName(@PathVariable(name = "clientName") String clientName) {
        List<TaskInfo> list = taskInfoService.getListByClientName(clientName);
        return Result.success(list);
    }
    @GetMapping("/qiandaotask/{clientName}/{userId}")
    public Result<QianDaoInfoVo> qianDaoTask(@PathVariable(name = "clientName") String clientName,@PathVariable(name = "userId") String userId) {
        QianDaoInfoVo qianDaoInfoVo = taskInfoService.qianDaoTask(clientName,userId);
        return Result.success(qianDaoInfoVo);
    }
    @GetMapping("/qiandao/{clientName}/{userId}")
    @OpLog(opType = "", opDesc = "签到")
    public Result<QianDaoInfoVo> qianDao(@PathVariable(name = "clientName") String clientName,@PathVariable(name = "userId") String userId) {
        QianDaoInfoVo qianDaoInfoVo = taskInfoService.qianDao(clientName,userId);
        return Result.success(qianDaoInfoVo);
    }
    @PostMapping("/finish")
    @OpLog(opType = "", opDesc = "完成任务")
    public Result<QianDaoInfoVo> finishTask(@RequestParam String clientName,@RequestParam String userId,@RequestParam Integer taskId) {
        QianDaoInfoVo qianDaoInfoVo = taskInfoService.finishTask(clientName,userId,taskId);
        return Result.success(qianDaoInfoVo);
    }
    @GetMapping("/yaoqin/{clientName}")
    public Result<List<TaskInfo>> yaoqinTask(@PathVariable(name = "clientName") String clientName) {
        List<TaskInfo> list = taskInfoService.getListByClientName(clientName);
        return Result.success(list.subList(2,5));
    }
    @GetMapping("/{userId}/{clientName}")
    public Result<List<TaskInfo>> getKbTaskInfo(@PathVariable(name = "clientName") String clientName,@PathVariable(name = "userId") String userId) {
        List<TaskInfo> list = taskInfoService.getKbTaskInfo(clientName,userId);
        return Result.success(list);
    }
}
